/**
 * 使用受限值
 * */

function minimumLength<T extends { length: number }>(
  obj: T,
  minimum: number
): T {
  if (obj.length > minimum) {
    return obj
  } else {
    return <T>{ length: minimum }
  }
}

const arr_restrain = minimumLength([1, 2, 3], 2)

console.log(arr_restrain);
// console.log(arr_restrain.slice(0))